home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Browser - Artopolis 97
/
browser.iso
/
mac
/
artrope
/
artrope.dir
/
00008_Script_Scroll Text Parent
< prev
next >
Wrap
Text File
|
1997-10-08
|
6KB
|
185 lines
property textMember, textSprite, barSprite, markSprite, markHeight, memberHeight, barHeight
---------------------------------------------------------------
-- PROPERTIES
--textMember = the current text member
--textSprite = the sprite the text sits in
--barSprite = the scroll bar
--markSprite = the marker that slides along barSprite
--markHeight = the height of the marker/slider; needed for positioning marker
--memberHeight = the height of the text member
--barHeight = the height of the scroll bar the slider moves along
--
--code is derived from Gary Rozenweig's "The Director 6.0 Book"
---------------------------------------------------------------
--==================================
--from the initFrame the scrollObject is created, passed
--the spriteNums for the below
------------------------------------
on new me, textSprite0, barSprite0, markSprite0
set textSprite = textSprite0
set textMember = the member of sprite textSprite
set barSprite = barSprite0
set markSprite = markSprite0
set the scrollTop of member textMember = 0
put the height of the rect of sprite markSprite into markHeight
put the height of the rect of textMember into memberHeight
put the height of the rect of sprite barSprite into barHeight
puppetSprite markSprite, TRUE
setMark(me)
return me
end
--==================================
--set the scrolltop of current textmember to 0
--depuppets the marker so it resets its position
------------------------------------
on resetMyStuff me
set the scrollTop of textMember = 0
puppetSprite markSprite, FALSE
end
--==================================
------------------------------------
on scrollOne me, x
scrollRichTextLine textMember, x
setMark(me)
updateStage
put the ticks into t
-- continue to scroll fast
repeat while the stillDown
if the ticks < t + 15 then next repeat -- delay after first movement
scrollRichTextLine textMember, x
setMark(me)
updateStage
end repeat
end
--==================================
--positions the markerSprite along the barSprite
------------------------------------
on setMark me
-- figure out where in the text field we are
put float(the scrollTop of textMember)/(memberHeight) into percent
-- set the mark to be in the right spot in along the bar
set the locV of sprite markSprite = the top of sprite barSprite + percent*(barHeight-markHeight)+(markHeight/2)
end
--==================================
--if the marker is clicked then we move the
--marker and the text while the mouseDown
------------------------------------
on moveMark me
repeat while the stillDown
-- constainly check teh vertical position of the mouse and set the field and mark
put the mouseV into v
put max(the top of sprite barSprite + markHeight/2,v) into v -- top limit
put min(the bottom of sprite barSprite - markHeight/2,v) into v -- bottom limit
set the locV of sprite markSprite = v
put float(v-the top of sprite barSprite-markHeight/2)/(barHeight-markHeight) into percent
set the scrollTop of textMember = (memberHeight*percent)
updateStage
end repeat
end
--==================================
-- when the user clicks on the bar, jump up or down by pages
--until the spot clicked is hit
------------------------------------
on clickBar me
put the locV of the clickLoc into v
-- scroll down by page
if v > the locV of sprite markSprite then
scrollRichTextPage textMember, 1
setMark(me)
updateStage
--delay after first movement
put the ticks into t
repeat while the ticks < t + 15
end repeat
-- continue to scroll fast
repeat while the stillDown and v > the locV of sprite markSprite
scrollRichTextPage textMember, 1
setMark(me)
updateStage
end repeat
-- scroll up by page
else
scrollRichTextPage textMember, -1
setMark(me)
updateStage
--delay after first movement
put the ticks into t
repeat while the ticks < t + 15
end repeat
-- continue to scroll fast
repeat while the stillDown and v < the locV of sprite markSprite
scrollRichTextPage textMember, -1
setMark(me)
updateStage
end repeat
end if
end
--==================================
--scrolls the text by line
--called from up/down arrows
------------------------------------
on scrollRichTextLine whichMember, x
put 14 into h -- the number of pixels in a line
if x = -1 then
if the scrollTop of whichMember - h < 0 then
set the scrollTop of whichMember = 0
else
set the scrollTop of whichMember = the scrollTop of whichMember - h
end if
else
if the scrollTop of whichMember + h > the height of whichMember-h then
set the scrollTop of whichMember = the height of whichMember- h
else
set the scrollTop of whichMember = the scrollTop of whichMember + h
end if
end if
end
--==================================
--when the barSprite is clicked, we
--scroll by line.
------------------------------------
on scrollRichTextPage whichMember, x
put the height of the rect of sprite textSprite into h -- the number of pixels in a line
if x = -1 then
if the scrollTop of whichMember - h < 0 then
set the scrollTop of whichMember = 0
else
set the scrollTop of whichMember = the scrollTop of whichMember - h
end if
else
if the scrollTop of whichMember + h > the height of whichMember-h then
set the scrollTop of whichMember = the height of whichMember- h
else
set the scrollTop of whichMember = the scrollTop of whichMember + h
end if
end if
end